/*
 * DeveloperTableModel.java
 *
 * Created on February 21, 2008, 7:00 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package projectprophet.app;

import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;
import projectprophet.core.*;

/**
 *
 * @author luppy
 */
public class DeveloperTableModel implements TableModel
{
	public DeveloperTableModel(Project inProject)
	{
		project = inProject;
	}
	public int getRowCount()
	{
		return project.getNumberOfDevelopers();
	}
	public int getColumnCount()
	{
		return 2;
	}
	public String getColumnName(int columnIndex)
	{
		return columnName[columnIndex];
	}
	public Class<?> getColumnClass(int columnIndex)
	{
		return columnClass[columnIndex];
	}
	public boolean isCellEditable(int rowIndex, int columnIndex)
	{
		return cellEditable[columnIndex];
	}

	public Object getValueAt(int rowIndex, int columnIndex)
	{
		Developer developer = project.getDeveloper(rowIndex);
		switch( columnIndex )
		{
			case 0:
				//return developer.get();
				return new Integer(rowIndex);
			case 1:
				return developer.getName();
			default:
				return "";
		}
	}
	public void setValueAt(Object aValue, int rowIndex, int columnIndex)
	{
		Developer developer = project.getDeveloper(rowIndex);
		switch( columnIndex )
		{
			case 1:
				developer.setName((String)aValue);
		}
	}
	
	public void addTableModelListener(TableModelListener l)
	{
	}
	public void removeTableModelListener(TableModelListener l)
	{
	}
	
	private Project project;
	private static String[]  columnName   = new String[] {"ID"         , "Name"      };
	private static Class[]   columnClass  = new Class[]  {Integer.class, String.class};
	private static boolean[] cellEditable = new boolean[]{false        , true        };
	
}
